Fox's Git Mirrors
Commit 71ca5427d400b4845f0e77a7a9e3836d73275e2c
Parents : dce8f20
Author : Grzegorz Milka <grzegorzmilka@gmail.com>
Date : 2022-11-13T18:48:59+01:00
fix: update numpy version to 1.23
Changes
Diff
diff --git a/pycodec2/pycodec2.pyx b/pycodec2/pycodec2.pyx
index 99d148e..ea1d197 100644
--- a/pycodec2/pycodec2.pyx
+++ b/pycodec2/pycodec2.pyx
@@ -44,7 +44,7 @@ cdef class Codec2:
frames = len(speech_in) // self.samples_per_frame()
bit_count = frames * self.bits_per_frame()
bits = b'\x00' * int(math.ceil(bit_count / 8.0))
- codec2_encode(self._c_codec2_state, bits, <short *>speech_in.data)
+ codec2_encode(self._c_codec2_state, bits, <short*>cnp.PyArray_DATA(speech_in))
return bits
def decode(self, bytes bits):
@@ -54,7 +54,7 @@ cdef class Codec2:
frames = int(math.floor((len(bits) * 8.0) / self.bits_per_frame()))
sample_count = frames * self.samples_per_frame()
speech_out = np.empty(sample_count, dtype=np.int16, order='C')
- codec2_decode(self._c_codec2_state, <short *>speech_out.data, bits)
+ codec2_decode(self._c_codec2_state, <short *>(cnp.PyArray_DATA(speech_out)), bits)
return speech_out
def decode_ber(self, bytes bits, float ber_est):
@@ -64,7 +64,7 @@ cdef class Codec2:
sample_count = frames * self.samples_per_frame()
speech_out = np.empty(sample_count, dtype=np.int16, order='C')
codec2_decode_ber(self._c_codec2_state,
- <short *>speech_out.data,
+ <short *>(cnp.PyArray_DATA(speech_out)),
bits,
ber_est)
return speech_out
@@ -90,7 +90,7 @@ cdef class Codec2:
return codec2_get_spare_bit_index(self._c_codec2_state)
def rebuild_spare_bit(self, cnp.ndarray[char, ndim=1] unpacked_bits):
- return codec2_rebuild_spare_bit(self._c_codec2_state, unpacked_bits.data)
+ return codec2_rebuild_spare_bit(self._c_codec2_state, <char *>cnp.PyArray_DATA(unpacked_bits))
def set_natural_or_gray(self, int gray):
codec2_set_natural_or_gray(self._c_codec2_state, gray)
diff --git a/setup.py b/setup.py
index d556d5e..ef5b7ca 100644
--- a/setup.py
+++ b/setup.py
@@ -12,7 +12,9 @@ ext_modules = [
"pycodec2/pycodec2.pyx",
],
include_dirs=[np.get_include()],
- define_macros=[("NPY_NO_DEPRECATED_API", "NPY_1_6_API_VERSION")],
+ # This line guarantees that we do not numpy API deprecated in
+ # 1.23.
+ define_macros=[("NPY_NO_DEPRECATED_API", "NPY_1_23_API_VERSION")],
libraries=["codec2"]) # Unix-like specific
]
Served by rngit 1.5.0 - Generated in 0.03s